package org.jzs.mybaseapp.section.home;

import org.jzs.mybaseapp.common.base.BaseApi;
import org.jzs.mybaseapp.common.system.AppConfig;
import org.jzs.mybaseapp.common.utils.MD5;
import org.jzs.mybaseapp.section.home.entity.CourseEntity;
import org.jzs.mybaseapp.section.home.entity.DsEntity;
import org.jzs.mybaseapp.section.home.entity.LoginEntity;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
 * Created by Jzs on 2017/7/29 0029.
 */

public class HomeApi extends BaseApi {

    private static HomeApi instance;

    public static HomeApi getInstance() {
        if (instance == null) {
            return new HomeApi();
        }
        return instance;
    }


    public HomeApi login(String phone, String pwd) {
        Map<String, String> maps = new HashMap<String, String>();
        maps.put("mobile", phone);
        maps.put("password", MD5.getMD5ofStr(pwd).toLowerCase(Locale.getDefault()));
        setConfig(AppConfig.LOGIN, maps, LoginEntity.class);
        return this;
    }

    public HomeApi dsapi(String baseurl) {
        Map<String, String> maps = new HashMap<String, String>();
        setConfig(baseurl, "", maps, DsEntity.class);
        return this;
    }

    public HomeApi courseDetail(String baseurl, String goodsId) {
        Map<String, String> maps = new HashMap<String, String>();
        maps.put("f", "xjj_course_detail");
        Map<String, String> jsonMaps = new HashMap<String, String>();
        jsonMaps.put("goodsId", goodsId);
        jsonMaps.put("shop", "xjj");
        jsonMaps.put("type", "2");
        jsonMaps.put("userId", "");
        jsonMaps.put("token", "");
        setConfig(baseurl, "api.php", maps, jsonMaps, CourseEntity.class);
        return this;
    }


}

